package design.patterns.mementomode.checkpointmemento;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2020-06-13 18:29
 */

public class MainTest {
    private static Originator o = new Originator();
    private static Caretaker c = new Caretaker(o);

    public static void main(String[] args) {
        o.setStates("state 0");
        c.createMemento();

        o.setStates("state 1");
        c.createMemento();

        o.setStates("state 2");
        c.createMemento();

        o.setStates("state 3");
        c.createMemento();

        o.setStates("state 4");
        c.createMemento();

        o.printState();

        System.out.println("Restoring to 2");
        c.restoreMemento(2);
        o.printState();

        System.out.println("Restoring to 0");
        c.restoreMemento(0);
        o.printState();

        System.out.println("Restoring to 3");
        c.restoreMemento(3);
        o.printState();
    }

}
